#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include "oled.h"
#include "mpu6050.h"


int main(int argc, char *argv[])
{
	int id;
    short AX, AY, AZ, GX, GY, GZ;
	if (argc != 1) {
		printf("Usage: %s\n");
		return -1;
	}

	OLED_Init();
	id = MPU6050_Init();
	if(id == -1) {
		printf("MPU6050 Init ERR!\n");
		return id;
	}
	OLED_ShowString(1, 1 , "MPU6050,ID:0x");
    OLED_ShowHexNum(1, 14, id, 2);
    printf("Starting...\r\n");
	while(1) {
        MPU6050_GetData(&AX, &AY, &AZ, &GX, &GY, &GZ);
		OLED_ShowSignedNum(2, 1, AX, 5);
		OLED_ShowSignedNum(3, 1, AY, 5);
		OLED_ShowSignedNum(4, 1, AZ, 5);
		OLED_ShowSignedNum(2, 8, GX, 5);
		OLED_ShowSignedNum(3, 8, GY, 5);
		OLED_ShowSignedNum(4, 8, GZ, 5);
		
	}
	return 0;
}